<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>库存查看</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%-- 引用layui.css --%>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>js/layui/css/layui.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>css/common.css" />
</head>
<body>
	<div class="ibox">
		<div class="ibox-content bodycss">
			<!-- 表单搜索 开始 -->
			<section class="panel panel-padding ">
				<form class="layui-form layui-form-pane form-search"
					onsubmit="return false" method="get">
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">商品名称</label>
						<div class="layui-input-inline">
							<input name="goods_name" id="goods_name" value="" placeholder="请输入商品名称"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">商品属性</label>
						<div class="layui-input-inline">
							<div style="width:150px">
								<select name="is_normal" id="is_normal">
									<option value="">请选择</option>
									<option value="0">正品</option>
									<option value="1">打折</option>
									<option value="2">体验</option>
									<option value="3">积分兑换</option>
									<option value="4">用来打包</option>
									<option value="7">可兑换打包品</option>
								</select>
							</div>
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<button class="layui-btn layui-btn-primary" lay-submit
							lay-filter="seach">
							<i class="layui-icon"></i> 搜索
						</button>
					</div>
				</form>
			</section>
			<!-- 表单搜索 结束 -->
			<section class="panel panel-padding ">
				<table class="layui-table"
					lay-data="{
	                        id: 'InventoryTeble',
	                        width:'auto',
	                        url:'inventory/findInventory.do',
	                        method:'post',
	                        page:true,
	                        even:true,
	                        skin:'row',
	                        limits:[10,20,30,40,50],
	                        limit:10}"
					lay-filter="popedomLay">
					<!-- lay-filter:监听 -->
					<thead>
						<tr>
							<th
								lay-data="{checkbox:true,disabledKey:'check_status',disabledKeyValue:'1,2'}"></th>
							<th lay-data="{type:'numbers', width:50}">序号</th>
							<th lay-data="{field:'goods_name', width:200,align:'center'}">商品名称</th>
							<th lay-data="{field:'specifications', width:120,align:'center'}">商品规格</th>
							<th lay-data="{field:'goods_destine_quota', width:200,align:'center'}">预定金额</th>
							<th
								lay-data="{field:'is_normal', width:200,align:'center',templet:'#m_type'}">订单状态</th>
								<th lay-data="{field:'goods_storage', width:200,align:'center'}">商品库存</th>
								<th lay-data="{field:'area_name', width:200,align:'center'}">所属服务点</th>
						</tr>
					</thead>
				</table>
			</section>
		</div>
	</div>
	<script type="text/html" id="m_type">	
	    {{#  if(d.is_normal == "0") {  }}
			<font color="#00ff00">正品</font>
		{{#  } else if(d.is_normal == "1") {  }}
			<font color="#ff0000">打折</font>
         {{#  } else if(d.is_normal == "2") {  }}
			<font color="#ff0000">体验</font>
		{{#  } else if(d.is_normal == "3") {  }}
			<font color="#ff0000">积分兑换</font>
		{{#  } else if(d.is_normal == "4") {  }}
			<font color="#ff0000">用来打包</font>
		{{#  } else if(d.is_normal == "7") {  }}
			<font color="#ff0000">可兑换打包品</font>
		{{#  }  }}
    </script>
	<script type="text/html" id="popedomBar">
			<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="orderOut">订单发货</button>
			<button class="layui-btn layui-bg-cyan layui-btn-xs" lay-event="orderExit">取消订单</button>
    </script>
	<script type="text/javascript" src="<%=basePath%>js/layui/layui.js"></script>
	<script type="text/javascript">
		layui.config({
			base : "<%=basePath%>/js/common/"
		}).use([ "common", "element", "layer", "form", "table", "jquery" ], function() {
			var elem = layui.element;
			var layer = layui.layer;
			var form = layui.form;
			var table = layui.table;
			var $ = layui.jquery;
			layui.common.init();
			/**
			 * 监听刷新表格
			 */
	
			/* 当点击搜索时，执行重载 */
			form.on('submit(seach)', function(data) {
				// layer.msg(JSON.stringify(data.field));
				table.reload('InventoryTeble', {
					where : data.field,
					page : {
						curr : 1
					}
				});
				return false;
			});
	
			//监听行工具事件
			table.on('tool(popedomLay)', function(obj) {
				var data = obj.data;
				var layEvent = obj.event;
				console.log(data);
				var id = data.orderId;
				console.log(obj.event);
	
				if (layEvent == "orderOut") {
					$.ajax({
						url : "order/updateState40.do",
						method : "post",
						data : {
							"orderId" : id
						},
						success : function(data1) {
							console.log(data1);
							if (data1.msg == "success") {
								table.reload('menuTeble', {
									where : data.field,
								//url : 'order/list.do'
								});
							}
						}
					});
					return false;
				} else if (layEvent == "orderExit") {
					$.ajax({
						url : "order/updateState0.do",
						method : "post",
						data : {
							"orderId" : id
						},
						success : function(data2) {
							console.log(data2);
							if (data2.msg == "success") {
								table.reload('menuTeble', {
									where : data.field,
								//url : 'order/list.do'
								});
							}
						}
					});
					return false;
				}
			});
	
	
	
	
			//导出Excel
			$("#exportExcel").on("click", function() {
				layer.load(2, {
					time : 1000
				});
				window.location.href = "order/export.do?orderSn=" + $("#orderSn").val() + "&userId=" + $("#userId").val() + "&userName=" + $("#userName").val() + "&orderState=" + $("#orderState").val();
			});
		});
	</script>
</body>
</html>
